package com.mercadoutils.controller;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.csvreader.CsvReader;
import com.mercadoutils.domain.Items;



public class importItemCsv {

	public static void main(String[] args) {
		
		try {
			
			List<Items> item = new ArrayList<Items>();
			
			CsvReader item_import = new CsvReader("C:/item_import.csv");
			item_import.setDelimiter(';');
			item_import.readHeaders();
			

			while (item_import.readRecord())
			{
				
				String title= item_import.get("title");
				String subtitle= item_import.get("subtitle");
				String price= item_import.get("price");
				String available_quantity= item_import.get("available_quantity");
				String description= item_import.get("description");
				String condition= item_import.get("condition");
				String warranty= item_import.get("waranty");
				
				item.add(new Items( title,subtitle,price,available_quantity,description,condition,warranty));				
			}
			
			item_import.close();
			
			for(Items itm : item){
			
				System.out.println("titulo:" + itm.getTitle() +" SubTi " +itm.getSubtitle() + " precio " +itm.getPrice()+" Cantidad "+itm.getAvailable_quantity()
					+ " Description "+ itm.getDescription()+" Condition "+ itm.getCondition()+" Garantia " +itm.getWarranty());
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}